<template>
  <el-select v-model="cur_value" placeholder="请选择职务" clearable>
    <el-option
      v-for="item in jobArray"
      :key="'jobArray' + item.id"
      :label="item.name"
      :value="item.name"
    />
  </el-select>
</template>

<script>
export default {
  name: "postSelect",
  props: {
    value: String,
  },
  data() {
    return {
      jobArray: [],
    };
  },
  computed: {
    cur_value: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("change", val);
      },
    },
  },
  created() {
    this.initJob();
  },
  methods: {
    initJob() {
        this.jobArray = [];
      var userInfoExp = this.$store.getters.userInfoExp;
      // 判断权限
      if (userInfoExp.bind_account == "admin") {
        this.jobArray = [
          { id: 1, key: "主管", name: "主管" },
          { id: 2, key: "组长", name: "组长" },
          { id: 3, key: "组员", name: "组员" },
        ];
      } else if (!userInfoExp.jurisdiction) {
        this.jobArray = [];
      } else if (userInfoExp.jurisdiction == "主管") {
        this.jobArray = [
          { id: 2, key: "组长", name: "组长" },
          { id: 3, key: "组员", name: "组员" },
        ];
      } else if (userInfoExp.jurisdiction == "组长") {
        this.jobArray = [{ id: 3, key: "组员", name: "组员" }];
      } else {
        this.jobArray = [];
      }
    },
  },
};
</script>

